package org.usp.poli.bipt.client.ui;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.DisclosurePanel;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.PasswordTextBox;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;

public class GenericDialog {
	private final DialogBox genericDialogBox = new DialogBox();
	private final FlexTable layout = new FlexTable();
	private Button okGeneric = new Button("OK");
    private Button cancelarGeneric = new Button("Cancelar");
    
	public GenericDialog(String title, String msg, Boolean cancelButton) {
		//--Diálogo de login
	    genericDialogBox.setGlassEnabled(true);
	    genericDialogBox.setAnimationEnabled(true);
	    VerticalPanel panelLogin = new VerticalPanel();
	    
	    // Create a table to layout the form options
	    
	    layout.setWidth("350px");
	    layout.setCellSpacing(6);
	    FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();

	    // Add a title to the form
	    layout.setHTML(0, 0, msg);
	    cellFormatter.setColSpan(0, 0, 2);
	    cellFormatter.setHorizontalAlignment(0, 0,
	        HasHorizontalAlignment.ALIGN_CENTER);

	    
	    HorizontalPanel botoes = new HorizontalPanel();
	    botoes.setSpacing(10);
	    botoes.add(okGeneric);
	    if(cancelButton)
	    	botoes.add(cancelarGeneric);
	    layout.setWidget(4,0,botoes);
	    cellFormatter.setColSpan(4, 0, 2);
	    cellFormatter.setHorizontalAlignment(4, 0,
		        HasHorizontalAlignment.ALIGN_CENTER);
	    panelLogin.add(layout);
	    genericDialogBox.setText(title);
	    genericDialogBox.add(panelLogin);
	    
	    
	}
	
	public Widget getBotaoOk(){
		return okGeneric;
	}
	
	public Widget getBotaoCancelar(){
		return cancelarGeneric;
	}
	
	public Widget getDialog(){
		return genericDialogBox;
	}
	

}
